﻿<Window x:Class="ContentFactory.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Toolkit="clr-namespace:DW.WPFToolkit;assembly=DW.WPFToolkit"
        xmlns:Toolkit2="clr-namespace:Xceed.Wpf.Toolkit.PropertyGrid;assembly=Xceed.Wpf.Toolkit"
        xmlns:Local="clr-namespace:ContentFactory"
        Title="Content Factory" Height="640" Width="1024" WindowStartupLocation="CenterScreen" WindowState="Maximized"
        PreviewMouseDown="Window_PreviewMouseDown" Closing="Window_Closing">
    <Window.Resources>
        <RoutedUICommand x:Key="Settings"/>
        <RoutedUICommand x:Key="Build"/>
        <RoutedUICommand x:Key="BuildAll"/>
        <RoutedUICommand x:Key="Update"/>
        <RoutedUICommand x:Key="Create"/>
        <RoutedUICommand x:Key="Import"/>
        <RoutedUICommand x:Key="Edit"/>
        <RoutedUICommand x:Key="AddDir"/>
        <RoutedUICommand x:Key="AddRoot"/>
        <Style TargetType="{x:Type Image}">
            <Setter Property="Width" Value="16"/>
            <Setter Property="Height" Value="16"/>
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="Opacity" Value="0.5"/>
                </Trigger>
            </Style.Triggers>
        </Style>
        <ControlTemplate x:Key="StateLabelTemplate" TargetType="{x:Type Label}">
            <TextBlock Name="TextBlock" HorizontalAlignment="Center" VerticalAlignment="Center"/>
            <ControlTemplate.Triggers>
                <Trigger Property="Content" Value="{StaticResource UnCreatedContentState}">
                    <Setter TargetName="TextBlock" Property="Text" Value="{DynamicResource MainWindow_TreeListView_State_UnCreated}"/>
                    <Setter TargetName="TextBlock" Property="Foreground" Value="Red"/>
                </Trigger>
                <Trigger Property="Content" Value="{StaticResource CreatingContentState}">
                    <Setter TargetName="TextBlock" Property="Text" Value="{DynamicResource MainWindow_TreeListView_State_Creating}"/>
                    <Setter TargetName="TextBlock" Property="Foreground" Value="Black"/>
                </Trigger>
                <Trigger Property="Content" Value="{StaticResource CreatedContentState}">
                    <Setter TargetName="TextBlock" Property="Text" Value="{DynamicResource MainWindow_TreeListView_State_Created}"/>
                    <Setter TargetName="TextBlock" Property="Foreground" Value="Green"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Key="I" Modifiers="Ctrl" Command="{StaticResource Import}" Gesture="Ctrl+I"/>
        <KeyBinding Key="D" Modifiers="Ctrl" Command="{StaticResource Create}" Gesture="Ctrl+D"/>
        <KeyBinding Key="B" Modifiers="Ctrl" Command="{StaticResource Build}" Gesture="Ctrl+B"/>
        <KeyBinding Key="B" Modifiers="Ctrl+Shift" Command="{StaticResource BuildAll}" Gesture="Ctrl+Shift+B"/>
    </Window.InputBindings>
    <Window.CommandBindings>
        <CommandBinding Command="New" CanExecute="Command_New_CanExecute" Executed="Command_New_Executed"/>
        <CommandBinding Command="Open" CanExecute="Command_Open_CanExecute" Executed="Command_Open_Executed"/>
        <CommandBinding Command="Save" CanExecute="Command_Save_CanExecute" Executed="Command_Save_Executed"/>
        <CommandBinding Command="SaveAs" CanExecute="Command_SaveAs_CanExecute" Executed="Command_SaveAs_Executed"/>
        <CommandBinding Command="Close" CanExecute="Command_Close_CanExecute" Executed="Command_Close_Executed"/>
        <CommandBinding Command="Replace" CanExecute="Command_Replace_CanExecute" Executed="Command_Replace_Executed"/>
        <CommandBinding Command="Delete" CanExecute="Command_Delete_CanExecute" Executed="Command_Delete_Executed"/>
        <CommandBinding Command="{StaticResource Settings}" CanExecute="Command_Settings_CanExecute" Executed="Command_Settings_Executed"/>
        <CommandBinding Command="{StaticResource Build}" CanExecute="Command_Build_CanExecute" Executed="Command_Build_Executed"/>
        <CommandBinding Command="{StaticResource BuildAll}" CanExecute="Command_BuildAll_CanExecute" Executed="Command_BuildAll_Executed"/>
        <CommandBinding Command="{StaticResource Update}" CanExecute="Command_Update_CanExecute" Executed="Command_Update_Executed"/>
        <CommandBinding Command="{StaticResource Import}" CanExecute="Command_Import_CanExecute" Executed="Command_Import_Executed"/>
        <CommandBinding Command="{StaticResource Create}" CanExecute="Command_Create_CanExecute" Executed="Command_Create_Executed"/>
        <CommandBinding Command="{StaticResource Edit}" CanExecute="Command_Edit_CanExecute" Executed="Command_Edit_Executed"/>
        <CommandBinding Command="{StaticResource AddDir}" CanExecute="Command_AddDir_CanExecute" Executed="Command_AddDir_Executed"/>
        <CommandBinding Command="{StaticResource AddRoot}" CanExecute="Command_AddRoot_CanExecute" Executed="Command_AddRoot_Executed"/>
    </Window.CommandBindings>
    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="{DynamicResource MainWindow_Menu_File}">
                <MenuItem Header="{DynamicResource MainWindow_Menu_File_New}" Command="New">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/New.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{DynamicResource MainWindow_Menu_File_Open}" Command="Open">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/Open.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{DynamicResource MainWindow_Menu_File_Save}" Command="Save">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/Save.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{DynamicResource MainWindow_Menu_File_SaveAs}" Command="SaveAs"/>
                <Separator />
                <MenuItem Header="{DynamicResource MainWindow_Menu_File_Settings}" Command="{StaticResource Settings}">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/Settings.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="{DynamicResource MainWindow_Menu_File_Close}" Command="Close"/>
            </MenuItem>
            <MenuItem Header="{DynamicResource MainWindow_Menu_Edit}">
                <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Create}" Command="{StaticResource Create}" InputGestureText="Ctrl+D">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/Create.png"/>
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Import}" Command="{StaticResource Import}" InputGestureText="Ctrl+I">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/Import.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Replace}" Command="Replace">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/Replace.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Edit}" Command="{StaticResource Edit}">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/Replace.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_AddDir}" Command="{StaticResource AddDir}">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/AddDir.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_AddRoot}" Command="{StaticResource AddRoot}">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/AddRoot.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Delete}" Command="Delete">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/Delete.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Build}" Command="{StaticResource Build}" InputGestureText="Ctrl+B">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/Build.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_BuildAll}" Command="{StaticResource BuildAll}" InputGestureText="Ctrl+Shift+B">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/BuildAll.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Update}" Command="{StaticResource Update}">
                    <MenuItem.Icon>
                        <Image Source="/ContentFactory;component/Images/Update.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Name="menuItemLanguages" Header="{DynamicResource MainWindow_Menu_Edit_Languages}"/>
            </MenuItem>
            <MenuItem Header="{DynamicResource MainWindow_Menu_Help}">
                <MenuItem Header="{DynamicResource MainWindow_Menu_Help_About}" Click="MenuItem_About_Click"/>
            </MenuItem>
        </Menu>
        <ToolBar DockPanel.Dock="Top">
            <Button Command="New" ToolTip="{DynamicResource MainWindow_ToolBar_New}">
                <Image Source="/ContentFactory;component/Images/New.png" />
            </Button>
            <Button Command="Open" ToolTip="{DynamicResource MainWindow_ToolBar_Open}">
                <Image Source="/ContentFactory;component/Images/Open.png" />
            </Button>
            <Button Command="Save" ToolTip="{DynamicResource MainWindow_ToolBar_Save}">
                <Image Source="/ContentFactory;component/Images/Save.png" />
            </Button>
            <Button Command="{StaticResource Settings}" ToolTip="{DynamicResource MainWindow_ToolBar_Settings}">
                <Image Source="/ContentFactory;component/Images/Settings.png" />
            </Button>
            <Separator />
            <Button Command="{StaticResource Create}" ToolTip="{DynamicResource MainWindow_ToolBar_Create}">
                <Image Source="/ContentFactory;component/Images/Create.png"/>
            </Button>
            <Button Command="{StaticResource Import}" ToolTip="{DynamicResource MainWindow_ToolBar_Import}">
                <Image Source="/ContentFactory;component/Images/Import.png"/>
            </Button>
            <Button Command="Replace" ToolTip="{DynamicResource MainWindow_ToolBar_Replace}">
                <Image Source="/ContentFactory;component/Images/Replace.png" />
            </Button>
            <Button Command="{StaticResource AddDir}" ToolTip="{DynamicResource MainWindow_ToolBar_AddDir}">
                <Image Source="/ContentFactory;component/Images/AddDir.png" />
            </Button>
            <Button Command="{StaticResource AddRoot}" ToolTip="{DynamicResource MainWindow_ToolBar_AddRoot}">
                <Image Source="/ContentFactory;component/Images/AddRoot.png" />
            </Button>
            <Button Command="Delete" ToolTip="{DynamicResource MainWindow_ToolBar_Delete}">
                <Image Source="/ContentFactory;component/Images/Delete.png"/>
            </Button>
            <Separator />
            <Button Command="{StaticResource Update}" ToolTip="{DynamicResource MainWindow_ToolBar_Update}">
                <Image Source="/ContentFactory;component/Images/Update.png" />
            </Button>
            <Button Command="{StaticResource BuildAll}" ToolTip="{DynamicResource MainWindow_ToolBar_BuildAll}">
                <Image Source="/ContentFactory;component/Images/BuildAll.png" />
            </Button>
            <Button Command="{StaticResource Build}" ToolTip="{DynamicResource MainWindow_ToolBar_Build}">
                <Image Source="/ContentFactory;component/Images/Build.png"/>
            </Button>
            <ComboBox Name="comboBoxPlatform" SelectedIndex="0" Width="160"/>
            <CheckBox Name="checkBoxChild" Content="{DynamicResource MainWindow_ToolBar_Child}" Margin="6,0,0,0" Style="{StaticResource {x:Type CheckBox}}"/>
            <CheckBox Name="checkBoxForced" Content="{DynamicResource MainWindow_ToolBar_Forced}" Margin="6,0,0,0" Style="{StaticResource {x:Type CheckBox}}"/>
        </ToolBar>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="240" />
            </Grid.ColumnDefinitions>
            <Grid Margin="0,0,6,0">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="160" />
                </Grid.RowDefinitions>
                <Toolkit:TreeListView Name="treeListView" SelectionMode="Single" MouseDoubleClick="TreeListView_MouseDoubleClick">
                    <Toolkit:TreeListView.Resources>
                        <HierarchicalDataTemplate DataType="{x:Type Local:ViewObject}" ItemsSource="{Binding Children}"/>
                    </Toolkit:TreeListView.Resources>
                    <Toolkit:TreeListView.View>
                        <GridView>
                            <GridViewColumn Header="{DynamicResource MainWindow_TreeListView_Column_Content}" Width="280">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <DockPanel>
                                            <Toolkit:TreeListViewExpander DockPanel.Dock="Left"/>
                                            <Image Source="{Binding Icon}" Width="20" Height="20" Margin="6,0" DockPanel.Dock="Left"/>
                                            <TextBlock Text="{Binding Name}" VerticalAlignment="Center" ToolTip="{Binding FileName}"/>
                                        </DockPanel>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="{DynamicResource MainWindow_TreeListView_Column_Windows}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Label Content="{Binding WindowsContentState}" Template="{StaticResource StateLabelTemplate}"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="{DynamicResource MainWindow_TreeListView_Column_Windows8}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Label Content="{Binding Windows8ContentState}" Template="{StaticResource StateLabelTemplate}"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="{DynamicResource MainWindow_TreeListView_Column_iOS}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Label Content="{Binding iOSContentState}" Template="{StaticResource StateLabelTemplate}"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="{DynamicResource MainWindow_TreeListView_Column_Android}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Label Content="{Binding AndroidContentState}" Template="{StaticResource StateLabelTemplate}"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="{DynamicResource MainWindow_TreeListView_Column_Linux}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Label Content="{Binding LinuxContentState}" Template="{StaticResource StateLabelTemplate}"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="{DynamicResource MainWindow_TreeListView_Column_OSX}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Label Content="{Binding OSXContentState}" Template="{StaticResource StateLabelTemplate}"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                            <GridViewColumn Header="{DynamicResource MainWindow_TreeListView_Column_PSM}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Label Content="{Binding PSMContentState}" Template="{StaticResource StateLabelTemplate}"/>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                        </GridView>
                    </Toolkit:TreeListView.View>
                    <Toolkit:TreeListView.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Create}" Command="{StaticResource Create}" InputGestureText="Ctrl+D">
                                <MenuItem.Icon>
                                    <Image Source="/ContentFactory;component/Images/Create.png"/>
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Import}" Command="{StaticResource Import}" InputGestureText="Ctrl+I">
                                <MenuItem.Icon>
                                    <Image Source="/ContentFactory;component/Images/Import.png" />
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Replace}" Command="Replace">
                                <MenuItem.Icon>
                                    <Image Source="/ContentFactory;component/Images/Replace.png" />
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Edit}" Command="{StaticResource Edit}">
                                <MenuItem.Icon>
                                    <Image Source="/ContentFactory;component/Images/Replace.png" />
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_AddDir}" Command="{StaticResource AddDir}">
                                <MenuItem.Icon>
                                    <Image Source="/ContentFactory;component/Images/AddDir.png" />
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_AddRoot}" Command="{StaticResource AddRoot}">
                                <MenuItem.Icon>
                                    <Image Source="/ContentFactory;component/Images/AddRoot.png" />
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Delete}" Command="Delete">
                                <MenuItem.Icon>
                                    <Image Source="/ContentFactory;component/Images/Delete.png" />
                                </MenuItem.Icon>
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_Build}" Command="{StaticResource Build}" InputGestureText="Ctrl+B">
                                <MenuItem.Icon>
                                    <Image Source="/ContentFactory;component/Images/Build.png" />
                                </MenuItem.Icon>
                            </MenuItem>
                            <MenuItem Header="{DynamicResource MainWindow_Menu_Edit_BuildAll}" Command="{StaticResource BuildAll}" InputGestureText="Ctrl+Shift+B">
                                <MenuItem.Icon>
                                    <Image Source="/ContentFactory;component/Images/BuildAll.png" />
                                </MenuItem.Icon>
                            </MenuItem>
                        </ContextMenu>
                    </Toolkit:TreeListView.ContextMenu>
                </Toolkit:TreeListView>
                <GridSplitter Height="6" HorizontalAlignment="Stretch" VerticalAlignment="Top" Grid.Row="1"/>
                <ListBox Name="listBox" Margin="0,6,0,0" Grid.Row="1"/>
            </Grid>
            <GridSplitter Width="6"/>
            <Grid Grid.Column="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition />
                    <RowDefinition Height="Auto"/>
                    <RowDefinition />
                </Grid.RowDefinitions>
                <GridSplitter Background="Transparent" Width="6" Margin="0,0,-3,0" HorizontalAlignment="Right" Grid.RowSpan="6"/>
                <Label Content="{DynamicResource MainWindow_Property_Name}" Margin="3,0"/>
                <TextBox Name="textBoxName" Text="{Binding Path=SelectedItem.Name,ElementName=treeListView}" Margin="3,0" VerticalAlignment="Center" Grid.Column="1"/>
                <Label Content="{DynamicResource MainWindow_Property_Compress}" Margin="3,0" Grid.Row="1"/>
                <CheckBox IsChecked="{Binding Path=SelectedItem.CompressContent,ElementName=treeListView}" Name="checkBoxCompress" Margin="3,0" VerticalAlignment="Center" Grid.Column="1" Grid.Row="1"/>
                <Label Content="{DynamicResource MainWindow_Property_Importer}" Margin="3,0" Grid.Row="2"/>
                <Toolkit2:PropertyGrid SelectedObject="{Binding Path=SelectedItem.Importer,ElementName=treeListView}" Grid.ColumnSpan="2" Grid.Row="3"
                                       PropertyValueChanged="PropertyGrid_PropertyValueChanged"/>
                <ComboBox Name="comboBoxImporter" SelectedItem="{Binding Path=SelectedItem.ImporterAttribute,ElementName=treeListView}" DisplayMemberPath="DisplayName" Margin="3,0" VerticalAlignment="Center" Grid.Column="1" Grid.Row="2"/>
                <Label Content="{DynamicResource MainWindow_Property_Processor}" Margin="3,0" Grid.Row="4"/>
                <ComboBox Name="comboBoxProcessor" SelectedItem="{Binding Path=SelectedItem.ProcessorAttribute,ElementName=treeListView}" DisplayMemberPath="DisplayName" Margin="3,0" VerticalAlignment="Center" Grid.Column="1" Grid.Row="4"/>
                <Toolkit2:PropertyGrid SelectedObject="{Binding Path=SelectedItem.Processor,ElementName=treeListView}" Grid.ColumnSpan="2" Grid.Row="5"
                                       PropertyValueChanged="PropertyGrid_PropertyValueChanged"/>
            </Grid>
        </Grid>
    </DockPanel>
</Window>
